<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8">
            //<![CDATA[
            function submitCheck()
            {
            	 document.getElementById("hiddenText_reservedSeats").style.display = "none";
                // check
                if(document.getElementById("reservedSeat").value == "")          
                    return false;
                else{
                	var seats = document.getElementById("reservedSeat").value;
                	if (seats.length >3)
                	{	
                		document.getElementById("hiddenText_reservedSeats").style.display = "inline";
                		document.getElementById("reservedSeat").value = "";
                		return false;
                	}
                }
                return true;
            }
            //]]>
        </script>
<title>Manager Center</title>
</head>
<body>
		<%@ page import="java.util.List"%>
        <%@ page import="model.ReservedSeat"%>
	<div id="container">
		<jsp:include page="includes/header.html" />
		<div class="main">
		    <div class="services">
		      <div class="service_bg">
		        <h3>Manager Center</h3>
		        <ul class="link">
		          <li>You can search, update, delete or add movies sections on page <a href="movieManagement.do"><strong>Movie Management</strong></a>.</li>
		          <li>You can search, delete or add officers on page <a href="OfficerManagement.do"><strong>Officer Management</strong></a>.</li>
		           <li>You can manage all sections' seats on page <a href="manageSeat.do"><strong>Manage Seats</strong></a></li>
           		 <li>If you want to view the statistic of movies and houses, please go to <a href="managerReport.do"><strong>Statistic</strong></a></li>
		          <li>If you want to log out, please <a href="logout.do"><strong>log out</strong></a>.</li>
		        </ul>
		        <div class="clr"></div>
           			 <div class="service_bg">
                    <h3>About the authors</h3>
                    <p><img src="images/user_pic.jpg" width="63" height="63" hspace="5" align="left" alt="picture" /><a href="#"><strong>ZHANG Niantong</strong></a><br />
                        Department of Computer Science, City University of Hong Kong</p>
                    <p><img src="images/user_pic.jpg" width="63" height="63" hspace="5" align="left" alt="picture" /><a href="#"><strong>ZHANG Hao</strong></a><br />
                         Department of Computer Science, City University of Hong Kong</p>
                         </div></div>
		      <div class="clr"></div>
		    </div>
		    <div class="global_main">
		      <div class="page_title_text">
		        <h1>Manage Seats</h1>
		      </div>
		      <% 
		       List<ReservedSeat> listReservedSeat = (List<ReservedSeat>) session.getAttribute("listReservedSeat");
		     	if (listReservedSeat.size()!=0)
		     	{
		      %>
		      <div class="clr"></div>
		       <div class="title">
                            <h3>Reserved Seats</h3>
                        </div>
                        <div class="clr"></div>
		     <%
                    if (session.getAttribute("errorMessage") != null) {
                        out.print("<h2>&nbsp;&nbsp;&nbsp;&nbsp;<strong><span style='color:red;'>Error: " + session.getAttribute("errorMessage") + "</span> </strong></h2>");
                        session.setAttribute("errorMessage", null);
                    }
        %>
        <table class="movieTable">
            <thead>
                <tr>
                    <th>House Id</th>
                    <th>Seat No</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                <%               
                            for (ReservedSeat reservedSeat : listReservedSeat) {
                                pageContext.setAttribute("reservedSeat", reservedSeat);
                %>
                <tr>
                    <td>${reservedSeat.houseId}</td>
                    <td>${reservedSeat.seatNo}</td>
                    <td>
                        <a
                            href="manageSeat.do?action=release&houseId=${reservedSeat.houseId}&seatNo=${reservedSeat.seatNo}">Release</a>
                    </td>
                </tr>
                <%
                            }
                %>
            </tbody>
        </table>
        <%
		     	}
		     	else{
		     		%>
		     		<h2 style="margin-left:20px;">There is no reserved seats!</h2>
		     		<% 
		     	}
        %>
        <form action="manageSeat.do" method="post" class="movieform" onsubmit="return submitCheck();">
            <input name="action" type="hidden" value="reserve" />
            <div>
                <label>House Id:</label>
                <select name="houseId">
                    <%
                                List<String> listHouseId = (List<String>) session.getAttribute("listHouseId");
                                for (String houseId : listHouseId) {
                    %>
                    <option value ="<%=houseId%>"><%=houseId%></option>
                    <%
                                }
                    %>
                </select>
            </div>
            <div>
                <label>Seat No</label> <input type="text" name="seatNo" id="reservedSeat" />
                 <span class="hiddenText" id="hiddenText_reservedSeats">No such a seat!</span>
            </div>
            <div class="button">
                <input type="submit" value="Reserve" />
                <input type="reset" value="Reset" />
            </div>

        </form>
		    </div>
		    <div class="clr"></div>
		  </div>
		<jsp:include page="includes/footer.html" />
	</div>
</body>
</html>